package net.janeluo.rs.module;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.janeluo.rs.entity.RS_Orders;
import net.janeluo.rs.entity.RS_User;
import net.janeluo.rs.service.MyOrderService;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 我的订单查询
 * 
 * @author DLK)JaneLuo
 * @version 1.0.0
 */
@IocBean
@At("/")
public class MyOrderModule {
    
    @Inject
    private MyOrderService myOrderService;
    
    /**
     * 初始化显示我的订单
     * @return 
     */
    @At("MyOrder")
    @Ok("jsp:views.MyOrder")
    public List<RS_Orders> myOrder(HttpServletRequest req, @Param("type") String type){
        RS_User user = (RS_User) req.getSession().getAttribute("user");
        List<RS_Orders> orderList = myOrderService.myOrderList(user.getUserid(), type);
        
        if ("1".equals(type)) {
            req.getSession().setAttribute("menuName", "LastMonth");
        } else {
            req.getSession().setAttribute("menuName", "BeforeMonth");
        }
        return orderList;
    }

}
